from extends.db import Base
from sqlalchemy.orm import Mapped, mapped_column
from sqlalchemy import String, ForeignKey
from .user import User

__all__ = ["ChatMessages"]

class ChatMessages(Base):
    """消息表
    """
    __tablename__ = "chat_messages"
    id: Mapped[int] = mapped_column(primary_key=True)
    content: Mapped[str] = mapped_column(String(30), comment="消息内容")
    withdraw: Mapped[bool] = mapped_column(default=False, comment="是否撤回")
    user: Mapped[User] = ForeignKey(User.id, comment="发送者")
    recipient: Mapped[User] = ForeignKey(User.id, comment="接受者")

    # def __repr__(self) -> str:
        # return f"Message(id={self.id!r}, content={self.content!r})"